namespace System;
/// <summary>
/// ConstructorInvoker`
/// </summary>
public sealed class ConstructorInvoker<T>
{
    /// <summary>
    /// 类型
    /// </summary>
    private readonly static Type t = typeof(T);
    /// <summary>
    /// 执行表达式
    /// </summary>
    private readonly static Expression[] ex = [Expression.New(t)];
    /// <summary>
    /// Expression
    /// </summary>
    private readonly static BlockExpression block = Expression.Block(t, ex);
    /// <summary>
    /// factory
    /// </summary>
    private readonly static Func<T> factory = Expression.Lambda<Func<T>>(block).Compile();
    /// <summary>
    /// 创建
    /// </summary>
    /// <returns></returns>
    public static T Build()
    {
        return factory();
    }
}